var disco;
(function (disco) {
    /// <reference path="../typings/jquery/jquery.d.ts" />
    /// <reference path="../typings/knockout/knockout.d.ts" />
    (function (core) {
        var DataManager = (function () {
            function DataManager() {
                this.data = null;
            }
            DataManager.prototype.get = function () {
                return this.data;
            };

            DataManager.prototype.set = function (value) {
                return this.data = value;
            };
            return DataManager;
        })();
        core.DataManager = DataManager;
    })(disco.core || (disco.core = {}));
    var core = disco.core;
})(disco || (disco = {}));

//why not disco.core? => quicker access
var disco;
(function (disco) {
    var Namespace = (function () {
        function Namespace() {
        }
        Namespace.remove = function (object) {
            return object.substr("Disco.Ontology.".length);
        };
        return Namespace;
    })();
    disco.Namespace = Namespace;

    var Collections = (function () {
        function Collections() {
        }
        Collections.contains = function (collection, predicate) {
            var result = jQuery.grep(collection, predicate);
            return result.length > 0;
        };

        Collections.where = function (collection, predicate) {
            var result = jQuery.grep(collection, predicate);
            return result;
        };

        Collections.single = function (collection, predicate) {
            var result = Collections.nullableSingle(collection, predicate);
            if (result)
                return result;
else
                throw new Error('The given predicate did not match one single item!');
        };

        Collections.nullableSingle = function (collection, predicate) {
            var result = jQuery.grep(collection, predicate);
            if (result.length == 1)
                return result[0];
else if (result.length == 0)
                return null;
else
                throw new Error('The given predicate matched more than one item!');
        };

        Collections.select = function (collection, selector) {
            var result = [];

            for (var item in collection) {
                result.push(selector(collection[item]));
            }

            return result;
        };

        Collections.implode = function (collection, delimiter) {
            var ret = '';

            collection.forEach(function (elem) {
                if (ret != '')
                    ret += delimiter;
                ret += elem;
            });

            return ret;
        };
        return Collections;
    })();
    disco.Collections = Collections;

    var Callbacks = (function () {
        function Callbacks() {
        }
        Callbacks.batch = function (batch, onFinish) {
            var _batch = function (i) {
                if (batch.length > i)
                    batch[i](_batch.bind(null, i + 1));
else if (onFinish)
                    onFinish();
            };
            _batch(0);
        };
        return Callbacks;
    })();
    disco.Callbacks = Callbacks;

    var Type = (function () {
        function Type() {
        }
        Type.get = function (variable) {
            return Object.prototype.toString.call(variable);
        };
        return Type;
    })();
    disco.Type = Type;
})(disco || (disco = {}));
